/******************* 公共变量 *******************/
var contactType = core.getUrlData('contact'),
	permissionObj = core.ls('permissionObj', 'o') || {},
	shouId = core.getUrlData('shou_id');
permissionObj.users = [];

$('html .contact-list .mui-bar-nav .mui-title, title').html((contactType == 'follow') ? '选择已关注' : ((contactType == 'fans') ? '选择粉丝' : ((contactType == 'contact') ? '玩伴' : '选择职业')));

if ((contactType == 'follow') || contactType == 'fans') {
	$('body').addClass('invite-contact');
} else if (contactType == 'contact') {
	$('body').addClass('user-contact');
} else {
	$('body').addClass('user-job');
}
(contactType == 'follow') ? $('body').addClass('invite-contact') : $('body').addClass('user-job');

/******************* 页面数据载入 *******************/
$.ajax({
	url: ((contactType == 'follow' ? getFollow : ((contactType == 'job' ? jobList : ((contactType == 'contact') ? contactListUrl : getFans))))),
	type: 'post',
	// data: {user_id: '1'},
	success: function(data) {
		console.log(data)
		var contactList = core.sortLetter({
				letter: data.list,
				city: data.list,
				prop: 'first_str',
				type: 1
			}),
			letter = '',
			contact = '';
		// console.log(JSON.stringify(contactList));
		// contactList = [
		// 	["L", "M", "N", "O", "P"],
		// 	[{
		// 		"letter": "L",
		// 		"name": [{
		// 			"user_id": "116",
		// 			"username": "立爷",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/YJN3CM9tzWvgKSbm5urVJhRl52JGLglyoYt1pia73nkjEyP4wVdhsrcKXib7TDAaZibibrpOwG75bmOSG4VibU7YcpQ/0",
		// 			"login_time": "1491741345",
		// 			"first_str": "L",
		// 			"introduction": null,
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 1,
		// 			"last_login": "2017-04-09",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "L",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "L",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "L",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "L",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}]
		// 	}, {
		// 		"letter": "M",
		// 		"name": [{
		// 			"user_id": "116",
		// 			"username": "立爷",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/YJN3CM9tzWvgKSbm5urVJhRl52JGLglyoYt1pia73nkjEyP4wVdhsrcKXib7TDAaZibibrpOwG75bmOSG4VibU7YcpQ/0",
		// 			"login_time": "1491741345",
		// 			"first_str": "M",
		// 			"introduction": null,
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 1,
		// 			"last_login": "2017-04-09",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "M",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "M",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "M",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "M",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}]
		// 	}, {
		// 		"letter": "N",
		// 		"name": [{
		// 			"user_id": "116",
		// 			"username": "立爷",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/YJN3CM9tzWvgKSbm5urVJhRl52JGLglyoYt1pia73nkjEyP4wVdhsrcKXib7TDAaZibibrpOwG75bmOSG4VibU7YcpQ/0",
		// 			"login_time": "1491741345",
		// 			"first_str": "N",
		// 			"introduction": null,
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 1,
		// 			"last_login": "2017-04-09",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "N",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "N",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "N",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "N",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}]
		// 	}, {
		// 		"letter": "O",
		// 		"name": [{
		// 			"user_id": "116",
		// 			"username": "立爷",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/YJN3CM9tzWvgKSbm5urVJhRl52JGLglyoYt1pia73nkjEyP4wVdhsrcKXib7TDAaZibibrpOwG75bmOSG4VibU7YcpQ/0",
		// 			"login_time": "1491741345",
		// 			"first_str": "O",
		// 			"introduction": null,
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 1,
		// 			"last_login": "2017-04-09",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "O",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "O",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "O",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "O",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}]
		// 	}, {
		// 		"letter": "P",
		// 		"name": [{
		// 			"user_id": "116",
		// 			"username": "立爷",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/YJN3CM9tzWvgKSbm5urVJhRl52JGLglyoYt1pia73nkjEyP4wVdhsrcKXib7TDAaZibibrpOwG75bmOSG4VibU7YcpQ/0",
		// 			"login_time": "1491741345",
		// 			"first_str": "P",
		// 			"introduction": null,
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 1,
		// 			"last_login": "2017-04-09",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "P",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "P",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "P",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}, {
		// 			"user_id": "2",
		// 			"username": "测试号2",
		// 			"sex": "1",
		// 			"photo_id": "http://wx.qlogo.cn/mmopen/7xZTMEK3l3WGReoVUAlwjIf9jDOfskzlLHWajjQsGOA9rp3DibAlfmO1oAmrRrVicnQicnzbGgpCUS3NGUO0YLRhzG27pgzythl/0",
		// 			"login_time": "1491108534",
		// 			"first_str": "P",
		// 			"introduction": "测试号不要用微信登录",
		// 			"lat": "24.48923061",
		// 			"lng": "118.10388605",
		// 			"is_friend": 0,
		// 			"last_login": "2017-04-02",
		// 			"distance": 0
		// 		}]
		// 	}]
		// ];
		for (var i = 0; i < contactList[0].length; i++) {
			letter += '<a>' + contactList[0][i] + '</a>';
			contact += '<li data-group="' + contactList[1][i].letter + '" class="mui-table-view-divider mui-indexed-list-group">' + contactList[1][i].letter + '</li>';
			if (contactType == 'job') {
				for (var j = 0; j < contactList[1][i].name.length; j++) {
					contact += '<li data-value="' + contactList[1][i].name[j].id + '" data-tags="' + contactList[1][i].name[j].id + '" class="mui-table-view-cell mui-indexed-list-item mui-checkbox mui-left"><input type="checkbox" />' + contactList[1][i].name[j].title + '</li>';
				}
			} else if (contactType == 'contact') {
				for (var j = 0; j < contactList[1][i].name.length; j++) {
					contact += '<li data-value="' + contactList[1][i].name[j].user_id + '" data-tags="' + contactList[1][i].name[j].user_id + '" user-id="' + contactList[1][i].name[j].user_id + '" class="mui-table-view-cell mui-indexed-list-item mui-checkbox mui-left">' + '<img src="' + contactList[1][i].name[j].photo_id + '" alt="" title="">' + contactList[1][i].name[j].username + '<span></span>' + '</li>';
				}
			} else {
				for (var j = 0; j < contactList[1][i].name.length; j++) {
					contact += '<li data-value="' + contactList[1][i].name[j].user_id + '" data-tags="' + contactList[1][i].name[j].user_id + '" class="mui-table-view-cell mui-indexed-list-item mui-checkbox mui-left"><input type="checkbox" />' + '<img src="' + contactList[1][i].name[j].photo_id + '" alt="" title="">' + contactList[1][i].name[j].username + '</li>';
				}
			}
		}
		$('html .contact-list .mui-indexed-list .mui-indexed-list-bar').html(letter);
		$('html .contact-list .mui-indexed-list .mui-indexed-list-inner .mui-table-view').html(contact);
		if (contactType == 'contact') {
			$('html .user-contact .mui-indexed-list .mui-indexed-list-inner .mui-table-view .mui-table-view-cell span').on('tap', function () {
				core.href(activityChatUrl + '?fa_id=' + $(this).parent().attr('user-id') + '&shou_id=' + shouId);
			});

			$('html .user-contact .mui-indexed-list .mui-indexed-list-inner .mui-table-view .mui-table-view-cell img').on('tap', function () {
				core.href(userDetailUrl + '?user_id=' + $(this).parent().attr('user-id') + '&from=1');
			});
		}
		/******************* 点击全选按钮 *******************/
		mui.init();
		mui.ready(function() {
			$('mui-indexed-list-search-input').attr('placeholder', (contactType == 'follow') ? '搜索已关注' : ((contactType == 'fans') ? '搜索粉丝' : ((contactType == 'contact') ? '搜索玩伴' : '搜索职业')));
			$('html .contact-list .mui-indexed-list .mui-indexed-list-search .mui-placeholder span:nth-child(2)').html((contactType == 'follow') ? '搜索已关注' : ((contactType == 'fans') ? '搜索粉丝' : ((contactType == 'contact') ? '搜索玩伴' : '搜索职业')));

			var header = document.querySelector('header.mui-bar');
			var list = document.getElementById('list');
			var done = document.getElementById('done');
			if (contactType == 'contact') {
				$('#done').css(dn);
			}
			if (contactType == 'job') {
				$('body').on('change', 'input[type="checkbox"]', function() {
					var $otherInput = $('li').eq($(this).parent().index()).siblings().children('input');
					for (var i = 0; i < $otherInput.length; i++) {
						$otherInput.eq(i)[0].checked = false;
					}
				});
			}
			//calc hieght
			list.style.height = ($(window).height() - header.offsetHeight) + 'px';
			// list.style.height = (document.body.offsetHeight - header.offsetHeight) + 'px';
			//create
			window.indexedList = new mui.IndexedList(list);
			//done event
			done.addEventListener('tap', function() {
				var checkboxArray = [].slice.call(list.querySelectorAll('input[type="checkbox"]'));
				var checkedValues = [],
					checkedId = [];
				checkboxArray.forEach(function(box) {
					if (box.checked) {
						checkedValues.push(box.parentNode.innerText);
						checkedId.push($(box.parentNode).attr('data-value'));
					}
				});
				console.log(checkedId)
				console.log(checkedValues)
				if (checkedValues.length > 0) {
					if (contactType == 'job') {
						$.ajax({
							url: userUpdateUrl,
							type: 'post',
							data: {
								job: checkedValues[0]
							},
							success: function(data) {
								console.log(data)

								if (data.status == 0) {
									core.layerHint(data.message);
								} else {
									core.hintBack(data.message);
								}
							}
						});
					} else {
						// for (var i = 0; i < checkedId.length; i++) {
						// 	permissionObj.users.push(checkedId[i]);
						// }
						permissionObj.users = checkedId;
						core.ls('permissionObj', 'o', permissionObj);
						core.back(-2);
					}
					// mui.alert('你选择了: ' + checkedValues);
				} else {
					(contactType == 'job') ? mui.alert('您没有选择任何职业'): mui.alert('您没有选择任何好友');
				}
			}, false);
			mui('.mui-indexed-list-inner').on('change', 'input', function() {
				var count = list.querySelectorAll('input[type="checkbox"]:checked').length;
				(contactType == 'job') && ((count >= 1) && (count = 1));
				var value = count ? "完成(" + count + ")" : "完成";
				done.innerHTML = value;
				if (count) {
					if (done.classList.contains("mui-disabled")) {
						done.classList.remove("mui-disabled");
					}
				} else {
					if (!done.classList.contains("mui-disabled")) {
						done.classList.add("mui-disabled");
					}
				}
			});
			var $letterBtn = $('html .contact-list .mui-indexed-list .mui-indexed-list-bar a, html .user-job .mui-indexed-list .mui-indexed-list-bar a'),
				averageLetterHeight = core.decimalRound($('html .contact-list .mui-indexed-list .mui-indexed-list-bar, html .user-job .mui-indexed-list .mui-indexed-list-bar').height() / $letterBtn.length, 2);
			if (averageLetterHeight < 20) {
				$letterBtn.css({
					height: averageLetterHeight + 'px',
					lineHeight: averageLetterHeight + 'px'
				});
			} else {
				$letterBtn.css({
					height: '20px',
					lineHeight: '20px'
				});
			}
		});
	}
});
